# -*- coding: utf-8 -*-
'''
@File  : file_name_replace.py
@Author: canx
@Date  : 2018/8/28 10:09
@Desc  : 文件名替换
'''
import os

def main():
    path = "E:/书法/练字/行书/tyz"
    exName = "gif"
    i = 0
    for fileName in os.listdir(path):
        i += 1
        print(fileName)

        if exName == None :
            exName = os.path.splitext(fileName)[1]

        newFileName = path + "/" + str(i) + "." + exName
        print(newFileName)
        os.rename(path + '/' + fileName, newFileName)


if __name__ == '__main__':
    main()